<?

if ($DATA['component']['id']) {
	
	$_plugin = 'Articles';
		
	$_table = 'data';				// where info is stored
	$_record = array('id_data' => D_MB_SETTINGS, 'id_parent' => $DATA['component']['id']);
	
	$_crit = "id_data=".D_MULTIBLOCK." AND value='$_plugin' AND attr & ".COM_ENABLED;	// data selection criterium

	$_defaults = array(
		'catalogs' => '', 'caption' => '', 'num' => 1, 'order' => 0, 'base' => ''
	);


	$DATA['objects'] = datafetch_array('db_list', array('table' => tb($_table), 'where' => $_crit, 'index' => 'id' ));

	switch (action(array('editor_save'))) {
	
		case 'editor_save':

			$temp = array();
			
			$_POST['catalogs'] = implode(',', (array)postdata('catalogs'));
		
			foreach($_defaults as $k => $v)
				if (($t = trim(postdata($k))) !== '')
					$temp[] = array_merge($_record, array('name' => $k, 'value' => $t));

			dataset('db_delete', tb('data'), "(id_data=".D_MB_SETTINGS.") AND (id_parent={$DATA[component][id]})");
			dataset('db_insert', tb('data'), $temp);
			
			return true;	// end of component edition
	}
	

	$DATA['settings'] = array_merge( $_defaults, datafetch_array('meta', D_MB_SETTINGS, $DATA['component']['id']));
	
	$DATA['settings']['catalogs'] = (array)explode(',', $DATA['settings']['catalogs']);
		
	return false;

} else exit;

?>